-
Notifications
You must be signed in to change notification settings - Fork 79
[GEN][ZH] Fix ThingTemplate override copy to prevent mismatch with mod map and quickstart #1194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[GEN][ZH] Fix ThingTemplate override copy to prevent mismatch with mod map and quickstart #1194
Conversation
//------------------------------------------------------------------------------------------------- | ||
void ThingTemplate::clearOnNewOverride() | ||
{ | ||
// TheSuperHackers @info Clear containers that may contain pointers to data in the 'parent' template for memoization purposes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Superfluous comment, because that is already explained with comments at the function declaration and the caller.
@@ -194,6 +194,9 @@ ThingTemplate* ThingFactory::newOverride( ThingTemplate *thingTemplate ) | |||
newTemplate->markAsOverride(); | |||
child->setNextOverride(newTemplate); | |||
|
|||
// TheSuperHackers @bugfix Caball009 25/06/2025 Clear data that was valid for the 'parent' template but not for the override. | |||
newTemplate->clearOnNewOverride(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what happens here is that the 2 SparseMatchFinder instances are copied first with *newTemplate = *child
, and then they are cleared here to purge the pointers to the unrelated vector of the other ThingTemplate.
There are 2 Problems:
Problem 1
It does not cover all copies automatically. There are 3 places that copy:
- In ThingFactory::newTemplate
- In ThingFactory::newOverride (this is covered by this change)
- In ThingTemplate::copyFrom
Problem 2
The 2 SparseMatchFinder instances are allocated and copied before they are cleared. Their allocated memory is probably kept on clear too. This is unnecessary work and can be avoided.
We do not want to implement ThingTemplate::operator=
by hand, because there are 80 or so class members. But there is something else we can do: #1234
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough.
Check out the information in the issue: #856 (comment)
Note: While this should fix all mismatching issues related to the default shellmap, custom map mismatches are not fixed. Custom maps with a map.ini file may still overwrite default data like
UpgradeTemplate
, which would almost certainly cause a mismatch on another map.